package com.lyuewei.ringtone.data; // 替换为你的数据类包名

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface RingerSettingDao {
    // 插入一个或多个 RingerSetting
    @Insert(onConflict = OnConflictStrategy.IGNORE) // 当发生冲突时忽略
    void insert(RingerSetting setting);

    // 更新一个或多个 RingerSetting
    @Update
    void update(RingerSetting setting);

    // 删除一个或多个 RingerSetting
    @Delete
    void delete(RingerSetting setting);


    @Query("SELECT * FROM ringer_settings WHERE enabled = 1 AND phone = :phone LIMIT 1")
    RingerSetting findEnabledByPhone(String phone);

    @Query("SELECT * FROM ringer_settings WHERE enabled = 1 AND id = 1 LIMIT 1")
    RingerSetting findEnabledByGlobal ();
    // 获取所有 RingerSetting
    @Query("SELECT * FROM ringer_settings ORDER BY id ASC") // 按名称升序排序
    LiveData<List<RingerSetting>> getAllSettings();

}
